package com.yidu.BusinessParameters.mapper;


import com.yidu.BusinessParameters.entity.CashAccruedEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface CashAccruedMapper {
    //查询
    @Select("SELECT * FROM cash AS c JOIN cashAccrued AS a ON c.cashId=a.cashId")
    public List<CashAccruedEntity> cashInventorySelect();
    //查询分页
    @Select("SELECT * FROM cash AS c JOIN cashAccrued AS a ON c.cashId=a.cashId WHERE 1=1 ${moneyAllocate} order by cashAccruedId limit #{page},#{limit} ")
    public List<CashAccruedEntity> cashInventorySelects(Map map);
    //增加
    @Insert("insert into cashAccrued values(#{cashAccruedId},#{fundId},#{cashId},#{cashDate},#{moneySun},#{moneyFlow},#{businessType})")
    public int cashInventoryinsert(CashAccruedEntity cashInventoryEntity);
    //删除
    @Delete("delete from cashAccrued where cashAccruedId=#{cashAccruedId}")
    public int cashInventorydelete(String cashAccruedId);
    //修改
    @Update("update cashAccrued set fundId=#{fundId},cashId=#{cashId},cashDate=#{cashDate},moneySun=#{moneySun},moneyFlow=#{moneyFlow},businessType=#{businessType} where cashAccruedId=#{cashAccruedId}")
    public int cashInventoryupdate(CashAccruedEntity cashInventoryEntity);

    @Delete("DELETE FROM cashAccrued WHERE cashDate=#{cashDate} AND fundId=#{fundId} AND cashId=#{cashId} AND businessType=#{businessType}")
    public int cashDeleteNew(CashAccruedEntity cashAccruedEntity);

    @Select("SELECT count(*) FROM cash AS c JOIN cashAccrued AS a ON c.cashId=a.cashId")
    int two();
}
